package com.zhl.media.commonsdk.http;

import com.zhl.media.commonsdk.data.UserUtil;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

public class HeaderInterceptor implements Interceptor {

    @Override
    public Response intercept(Chain chain) throws IOException {
        if (chain.request().url().toString().contains("token")) {
            return chain.proceed(chain.request());
        }
        String token = UserUtil.getTokenInfo().getAccess_token();
        Request request = chain.request().newBuilder().addHeader("Authorization", "Bearer" + token).build();
        return chain.proceed(request);
    }
}